const db = require('../db/index');

const menuMap = {
  '超级管理员': [{
        path: '/home',
        name: 'home',
        component: './home/index'
      },
      {
        path: '/system',
        name: 'system',
        component: './system/index'
      },
      {
        path: '/overView',
        name: 'overView',
        component: './overView/index'
      },
      {
        path: '/message_manage',
        name: 'message_manage',
        component: './users-manage/message-manage/index'
      },
      {
        path: '/product_manage',
        name: 'product_manage',
        component: './users-manage/product-manage/index'
      },
      {
        path: '/user_manage',
        name: 'user_manage',
        component: './users-manage/user-manage/index'
      },
      {
        path: '/user_list',
        name: 'user_list',
        component: './users-manage/user-list/index'
      },
      {
        path: '/product_list',
        name: 'product_list',
        component: './product-manage/product-list/index'
      },
      {
        path: '/out_product_list',
        name: 'out_product_list',
        component: './product-manage/out-product-list/index'
      },
      {
        path: '/message_list',
        name: 'message_list',
        component: './message-manage/message-list/index'
      },
      {
        path: '/message_recive',
        name: 'message_recive',
        component: './message-manage/revice/index'
      },
      {
        path: '/file',
        name: 'file',
        component: './file/index'
      },
      {
        path: '/login_log',
        name: 'login_log',
        component: './log/login_log/index'
      },
      {
        path: '/operate_log',
        name: 'operate_log',
        component: './log/operate_log/index'
      },
    ],
  '用户管理员': [{
        path: '/home',
        name: 'home',
        component: './home/index'
      },
      {
        path: '/system',
        name: 'system',
        component: './system/index'
      },
      {
        path: '/overView',
        name: 'overView',
        component: './overView/index'
      },
      {
        path: '/message_manage',
        name: 'message_manage',
        component: './users-manage/message-manage/index'
      },
      {
        path: '/product_manage',
        name: 'product_manage',
        component: './users-manage/product-manage/index'
      },
      {
        path: '/user_manage',
        name: 'user_manage',
        component: './users-manage/user-manage/index'
      },
      {
        path: '/user_list',
        name: 'user_list',
        component: './users-manage/user-list/index'
      },
      {
        path: '/product_list',
        name: 'product_list',
        component: './product-manage/product-list/index'
      },
      {
        path: '/out_product_list',
        name: 'out_product_list',
        component: './product-manage/out-product-list/index'
      },
      {
        path: '/message_list',
        name: 'message_list',
        component: './message-manage/message-list/index'
      },
      {
        path: '/message_recive',
        name: 'message_recive',
        component: './message-manage/revice/index'
      },
      {
        path: '/file',
        name: 'file',
        component: './file/index'
      },
      {
        path: '/login_log',
        name: 'login_log',
        component: './log/login_log/index'
      },
      {
        path: '/operate_log',
        name: 'operate_log',
        component: './log/operate_log/index'
      },

    ],
  '消息管理员': [{
        path: '/home',
        name: 'home',
        component: './home/index'
      },
      {
        path: '/system',
        name: 'system',
        component: './system/index'
      },
      {
        path: '/overView',
        name: 'overView',
        component: './overView/index'
      },
      {
        path: '/message_manage',
        name: 'message_manage',
        component: './users-manage/message-manage/index'
      },
      {
        path: '/product_manage',
        name: 'product_manage',
        component: './users-manage/product-manage/index'
      },
      {
        path: '/user_manage',
        name: 'user_manage',
        component: './users-manage/user-manage/index'
      },
      {
        path: '/user_list',
        name: 'user_list',
        component: './users-manage/user-list/index'
      },
      {
        path: '/product_list',
        name: 'product_list',
        component: './product-manage/product-list/index'
      },
      {
        path: '/out_product_list',
        name: 'out_product_list',
        component: './product-manage/out-product-list/index'
      },
      {
        path: '/message_list',
        name: 'message_list',
        component: './message-manage/message-list/index'
      },
      {
        path: '/message_recive',
        name: 'message_recive',
        component: './message-manage/revice/index'
      },
      {
        path: '/file',
        name: 'file',
        component: './file/index'
      },
      {
        path: '/login_log',
        name: 'login_log',
        component: './log/login_log/index'
      },
      {
        path: '/operate_log',
        name: 'operate_log',
        component: './log/operate_log/index'
      },

    ],
  '产品管理员': [{
        path: '/home',
        name: 'home',
        component: './home/index'
      },
      {
        path: '/system',
        name: 'system',
        component: './system/index'
      },
      {
        path: '/overView',
        name: 'overView',
        component: './overView/index'
      },
      {
        path: '/message_manage',
        name: 'message_manage',
        component: './users-manage/message-manage/index'
      },
      {
        path: '/product_manage',
        name: 'product_manage',
        component: './users-manage/product-manage/index'
      },
      {
        path: '/user_manage',
        name: 'user_manage',
        component: './users-manage/user-manage/index'
      },
      {
        path: '/user_list',
        name: 'user_list',
        component: './users-manage/user-list/index'
      },
      {
        path: '/product_list',
        name: 'product_list',
        component: './product-manage/product-list/index'
      },
      {
        path: '/out_product_list',
        name: 'out_product_list',
        component: './product-manage/out-product-list/index'
      },
      {
        path: '/message_list',
        name: 'message_list',
        component: './message-manage/message-list/index'
      },
      {
        path: '/message_recive',
        name: 'message_recive',
        component: './message-manage/revice/index'
      },
      {
        path: '/file',
        name: 'file',
        component: './file/index'
      },
      {
        path: '/login_log',
        name: 'login_log',
        component: './log/login_log/index'
      },
      {
        path: '/operate_log',
        name: 'operate_log',
        component: './log/operate_log/index'
      },

    ],
  '用户': [{
        path: '/home',
        name: 'home',
        component: './home/index'
      },
      {
        path: '/system',
        name: 'system',
        component: './system/index'
      },
      {
        path: '/overView',
        name: 'overView',
        component: './overView/index'
      },
      {
        path: '/message_manage',
        name: 'message_manage',
        component: './users-manage/message-manage/index'
      },
      {
        path: '/product_manage',
        name: 'product_manage',
        component: './users-manage/product-manage/index'
      },
      {
        path: '/user_manage',
        name: 'user_manage',
        component: './users-manage/user-manage/index'
      },
      {
        path: '/user_list',
        name: 'user_list',
        component: './users-manage/user-list/index'
      },
      {
        path: '/product_list',
        name: 'product_list',
        component: './product-manage/product-list/index'
      },
      {
        path: '/out_product_list',
        name: 'out_product_list',
        component: './product-manage/out-product-list/index'
      },
      {
        path: '/message_list',
        name: 'message_list',
        component: './message-manage/message-list/index'
      },
      {
        path: '/message_recive',
        name: 'message_recive',
        component: './message-manage/revice/index'
      },
      {
        path: '/file',
        name: 'file',
        component: './file/index'
      },
      {
        path: '/login_log',
        name: 'login_log',
        component: './log/login_log/index'
      },
      {
        path: '/operate_log',
        name: 'operate_log',
        component: './log/operate_log/index'
      },

    ],
}


// 根据部门/id获取菜单列表
exports.getMenuList = (req, res) => {
  let sql = 'select identity from users where id=?';
  db.query(sql, req.query.id, (err, results) => {
    if (err) return res.cc(err);
    if (results.length === 0) return res.cc('该用户还未添加部门')
    res.send({
      status: 0,
      identity:results[0].identity,
      menuList: menuMap[results[0].identity]
    })

  })
}
